Optimal. Leaf size=87 \[ \frac {x}{b^2}-\frac {2 a \left (a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \left (a^2-b^2\right )^{3/2}}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.10, antiderivative size = 87, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.385, Rules used = {2869, 2814,
2739, 632, 210} \begin {gather*} -\frac {2 a \left (a^2-2 b^2\right ) \text {ArcTan}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{b^2 \left (a^2-b^2\right )^{3/2}}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {x}{b^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 210
Rule 632
Rule 2739
Rule 2814
Rule 2869
Rubi steps
\begin {align*} \int \frac {\sin ^2(x)}{(a+b \sin (x))^2} \, dx &=\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {\int \frac {a b+\left (a^2-b^2\right ) \sin (x)}{a+b \sin (x)} \, dx}{b \left (a^2-b^2\right )}\\ &=\frac {x}{b^2}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}-\frac {\left (a \left (a^2-2 b^2\right )\right ) \int \frac {1}{a+b \sin (x)} \, dx}{b^2 \left (a^2-b^2\right )}\\ &=\frac {x}{b^2}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}-\frac {\left (2 a \left (a^2-2 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^2 \left (a^2-b^2\right )}\\ &=\frac {x}{b^2}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {\left (4 a \left (a^2-2 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b^2 \left (a^2-b^2\right )}\\ &=\frac {x}{b^2}-\frac {2 a \left (a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{b^2 \left (a^2-b^2\right )^{3/2}}+\frac {a^2 \cos (x)}{b \left (a^2-b^2\right ) (a+b \sin (x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.16, size = 83, normalized size = 0.95 \begin {gather*} \frac {x-\frac {2 a \left (a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}+\frac {a^2 b \cos (x)}{(a-b) (a+b) (a+b \sin (x))}}{b^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.23, size = 121, normalized size = 1.39
method | result | size |
default | \(\frac {2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )}{b^{2}}-\frac {2 a \left (\frac {-\frac {b^{2} \tan \left (\frac {x}{2}\right )}{a^{2}-b^{2}}-\frac {a b}{a^{2}-b^{2}}}{a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 b \tan \left (\frac {x}{2}\right )+a}+\frac {\left (a^{2}-2 b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\left (a^{2}-b^{2}\right )^{\frac {3}{2}}}\right )}{b^{2}}\) | \(121\) |
risch | \(\frac {x}{b^{2}}-\frac {2 i a^{2} \left (i b +a \,{\mathrm e}^{i x}\right )}{b^{2} \left (a^{2}-b^{2}\right ) \left (-i b \,{\mathrm e}^{2 i x}+i b +2 a \,{\mathrm e}^{i x}\right )}+\frac {a^{3} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) b^{2}}-\frac {2 a \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right )}-\frac {a^{3} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) b^{2}}+\frac {2 a \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right )}\) | \(360\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 167 vs.
\(2 (81) = 162\).
time = 0.44, size = 403, normalized size = 4.63 \begin {gather*} \left [\frac {2 \, {\left (a^{4} b - 2 \, a^{2} b^{3} + b^{5}\right )} x \sin \left (x\right ) - {\left (a^{4} - 2 \, a^{2} b^{2} + {\left (a^{3} b - 2 \, a b^{3}\right )} \sin \left (x\right )\right )} \sqrt {-a^{2} + b^{2}} \log \left (-\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} - 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{5} - 2 \, a^{3} b^{2} + a b^{4}\right )} x + 2 \, {\left (a^{4} b - a^{2} b^{3}\right )} \cos \left (x\right )}{2 \, {\left (a^{5} b^{2} - 2 \, a^{3} b^{4} + a b^{6} + {\left (a^{4} b^{3} - 2 \, a^{2} b^{5} + b^{7}\right )} \sin \left (x\right )\right )}}, \frac {{\left (a^{4} b - 2 \, a^{2} b^{3} + b^{5}\right )} x \sin \left (x\right ) + {\left (a^{4} - 2 \, a^{2} b^{2} + {\left (a^{3} b - 2 \, a b^{3}\right )} \sin \left (x\right )\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) + {\left (a^{5} - 2 \, a^{3} b^{2} + a b^{4}\right )} x + {\left (a^{4} b - a^{2} b^{3}\right )} \cos \left (x\right )}{a^{5} b^{2} - 2 \, a^{3} b^{4} + a b^{6} + {\left (a^{4} b^{3} - 2 \, a^{2} b^{5} + b^{7}\right )} \sin \left (x\right )}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] Timed out
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Timed out} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.46, size = 124, normalized size = 1.43 \begin {gather*} -\frac {2 \, {\left (a^{3} - 2 \, a b^{2}\right )} {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{{\left (a^{2} b^{2} - b^{4}\right )} \sqrt {a^{2} - b^{2}}} + \frac {2 \, {\left (a b \tan \left (\frac {1}{2} \, x\right ) + a^{2}\right )}}{{\left (a^{2} b - b^{3}\right )} {\left (a \tan \left (\frac {1}{2} \, x\right )^{2} + 2 \, b \tan \left (\frac {1}{2} \, x\right ) + a\right )}} + \frac {x}{b^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 9.95, size = 2562, normalized size = 29.45 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________